<?php
global $_GPC, $_W;
$GLOBALS['frames'] = $this->getMainMenu();
$user = pdo_fetchall("SELECT * FROM " . tablename('snx_teacher') . " WHERE uniacid= :uniacid ORDER BY id DESC", array(':uniacid' => $_W['uniacid']), 'id');
$info=pdo_get('ims_snx_hx',array('id'=>$_GPC['id']));
if(checksubmit('submit')){
        $data['user_id']=0;       
        $data['hx_id']=$_GPC['user_id'];
        $data['time']=date("Y-m-d H:i:s",time());         
        $data['uniacid']=$_W['uniacid'];
     if($_GPC['id']==''){  
        if($_GPC['user_id']==0){
            message('核销员不能为空!', $this->createWebUrl('addhx'), 'error');
        }else{
            $u=pdo_get('ims_snx_hx',array('hx_id'=>$_GPC['user_id']));
            if($u){
                message('该核销员已存在!', $this->createWebUrl('addhx'), 'error');
            }else{
                $res=pdo_insert('ims_snx_hx',$data);
                if($res){
                     message('添加成功！', $this->createWebUrl('hxlist'), 'success');
                }else{
                     message('添加失败！','','error');
                }
            }
        }
    }else{
        $res=pdo_update('ims_snx_hx',$data,array('id'=>$_GPC['id']));
        if($res){
             message('编辑成功！', $this->createWebUrl('hxlist'), 'success');
        }else{
             message('编辑失败！','','error');
        }
    }
}

include $this->template('web/addhx');